<form action="/manager.php?app=relation&act=edit" method="post" id="relation_edit_form">
	<div class="tabs">
		<ul>
			<li><a href="#base">基本信息</a></li>
			!{if $id}
			<li><a href="#item">关联属性</a></li>
			!{/if}
		</ul>
		<div id="base">
			<div class="tabs">
				<ul>
					!{foreach from=$site_langs item=lan_name key=lan}
					<li><a href="#lan_!{$lan}">!{$lan_name}</a></li>
					!{/foreach}
				</ul>
				!{foreach from=$site_langs item=lan_name key=lan}
				<div id="lan_!{$lan}">
					<div class="form_item">
						<strong>名称：</strong>
						<div><input class="text_input" maxlength="50" type="text" name="!{$lan}_name" value="!{$relation.$lan.name}"/></div>
						<p>(名称长度应该在1至50之间)</p>
					</div>
					<div class="form_item">
						<strong>描述：</strong>
						<div><input class="text_input" maxlength="50" type="text" name="!{$lan}_desc" value="!{$relation.$lan.desc}"/></div>
					</div>
				</div>
				!{/foreach}
			</div>
			<div class="form_item">
				<strong>代码：</strong>
				<div><input class="text_input" maxlength="50" type="text" name="code" value="!{$relation.code}"/></div>
				<p>(请使用字母和数字，以字母开头)</p>
			</div>
			<div class="form_item">
				<strong>所有者：</strong>
				<div>
					<select name="owner">
						!{html_options options=$owners selected=$relation.owner}
					</select> 
				</div>
				<p>所有者是系统时，将不允许网站管理员修改、删除</p>
			</div>
		</div>
		!{if $id}
		<div id="item">
			<div class="form_item">
				<input class="button" id="new_item" type="button" value="新增" onclick="edit_item('!{$id}')"/>
			</div>
			<ul class="list_view">
			!{foreach from=$relations item=r key=rid}
				<li id="rid_!{$rid}">
					<strong>
						!{$r.name}
						!{if $r.desc}<span>(!{$r.desc})</span>!{/if}
					</strong>
					<div class="opt_div">
						<a href="javascript:void(0)" onclick="edit_item('!{$id}', '!{$rid}')"><span class="ui-icon ui-icon-pencil"></span>修改</a>
						<a href="javascript:void(0)" onclick="del_item('!{$id}','!{$rid}')"><span class="ui-icon ui-icon-trash"></span>删除</a> 
					</div>
				</li>
			!{foreachelse}
				<li>暂无记录！</li>
			!{/foreach}
			</ul>
		</div>
		!{/if}
	</div>
	<div class="form_item form_btn_item">
		<input class="button main submit" type="button" value="保存" />
		<input type="hidden" name="id" value="!{$id|default:0}" />
	</div>
</form>
<div id="temp_dir">
	<select name="parent">
		<option value="0">--顶级--</option>
		!{html_options options=$options}
	</select>
</div>
<script>
	$(function(){
		$('#parent_div').html($('#temp_dir').html());
		$('#relation_edit_form .tabs').tabs();
		$('#relation_edit_form').ajax_form({
			'submit_btn' : '.submit',
			'success' : function(form, data){
				var id = data.data;
				$(form).html("正在重新载入").load('/manager.php?app=relation&act=edit&id=' + id);
			}
		});
		$('#relation_edit_form .button').button();
	});
</script>